#include"CollisionLineBox.h"

/////////////////
//include
/////////////////
#include"Game.h"
#include<ANX/Mouse.h>
/////////////////
//prottype
/////////////////

/////////////////
//const
/////////////////


CollisionLineBox::CollisionLineBox()
{
	edit_rect = EditRect();
	edit_rect2 = EditRect();
	line = Line2D();
}
CollisionLineBox::~CollisionLineBox()
{
}

void CollisionLineBox::Init()
{
	edit_rect.Init();
	edit_rect.SetStartPos(Vector2D(100,100));
	edit_rect.SetEndPos(Vector2D(-100,-100));

	edit_rect2.Init();
	edit_rect2.SetStartPos(Vector2D(100,-100));
	edit_rect2.SetEndPos(Vector2D(-100,100));
}
void CollisionLineBox::ContentLoad(Device* device)
{
	edit_rect.ContentLoad();
	edit_rect2.ContentLoad();
}
void CollisionLineBox::Update()
{
	edit_rect.Update();
	edit_rect2.Update();
}
void CollisionLineBox::Draw(DeviceContext* device_context)
{
	//Game::sprite_drawer->DrawEditRect(edit_rect);
	Game::sprite_drawer->DrawLine(edit_rect.GetStartPos(),edit_rect.GetEndPos());
	Game::sprite_drawer->DrawRect(Rect(edit_rect.GetStartPos().x,edit_rect.GetStartPos().y,RECT_SIZE,RECT_SIZE));
	Game::sprite_drawer->DrawRect(Rect(edit_rect.GetEndPos().x,edit_rect.GetEndPos().y,RECT_SIZE,RECT_SIZE));

	Game::sprite_drawer->DrawLine(edit_rect2.GetStartPos(),edit_rect2.GetEndPos());
	Game::sprite_drawer->DrawRect(Rect(edit_rect2.GetStartPos().x,edit_rect2.GetStartPos().y,RECT_SIZE,RECT_SIZE));
	Game::sprite_drawer->DrawRect(Rect(edit_rect2.GetEndPos().x,edit_rect2.GetEndPos().y,RECT_SIZE,RECT_SIZE));

	line.start		= edit_rect.GetStartPos();
	line2.start		= edit_rect2.GetStartPos();

	line.end		= edit_rect.GetEndPos();
	line2.end		= edit_rect2.GetEndPos();
	Vector2D tmp_collision_pos = line.CollisionPoint(line2);
	if(tmp_collision_pos != Vector2D::GetWrongParameter())
		Game::sprite_drawer->DrawRect(Rect(tmp_collision_pos.x,tmp_collision_pos.y,10,10));
	Game::sprite_drawer->DrawRect(Rect(Mouse::GetPos().ChengeScreenPos().x,Mouse::GetPos().ChengeScreenPos().y,RECT_SIZE,RECT_SIZE));




	Game::sprite_drawer->DrawRect(Rect(line.start,line.end));
	Game::sprite_drawer->DrawRect(Rect(line2.start,line2.end));
	//Vector2D tmp_mouse_pos = Mouse::GetPos().ChengeScreenPos();
	//Game::sprite_drawer->DrawRect(Rect(tmp_mouse_pos.x,tmp_mouse_pos.y,RECT_SIZE,RECT_SIZE));
	//printf("x = %f,y = %f\n",tmp_mouse_pos.x,tmp_mouse_pos.y);
}